package com.wyman.factory.support;

import com.wyman.factory.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author 李伟民
 * @Description  存放容器创建出来的单例对象
 * @DateTime 2024/11/25 01:46
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {


    private final ConcurrentHashMap<String,Object> singletonObjects = new ConcurrentHashMap<>();

    @Override
    public Object getSingleton(String beanName) {
        return singletonObjects.get(beanName);
    }

    protected void addSingleton(String beanName,Object singletonObject){
        singletonObjects.put(beanName,singletonObject);
    }
}
